package com.wangzh.utils;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

@Component
public class CodeUtils {

    private String [] patch = {"000000","00000","0000","000","00","0",""};
    public String generator(String tele) {
        int hash = tele.hashCode();

        int encryptionn = 2020666;
        long reslut = hash ^ encryptionn;
        long l = System.currentTimeMillis();
        reslut = reslut ^ l;
        long code = reslut % 1000000;
        code = code<0?-code:code;
        String codeStr = code + "";
        int len = codeStr.length();

        return  patch[len]+codeStr;
    }

    @Cacheable(value = "smsCode",key = "#tele")
    public String getCacheCode(String tele){

        return null;
    }
}
